package com.huan.lossless.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.stereotype.Component;

/**
 * 打印调用下游服务的日志
 *
 * @author huan.fu
 * @date 2023/6/10 - 21:36
 */
@Slf4j
@Component
public class CustomLoadBalancerClientFactory extends LoadBalancerClientFactory {
    public CustomLoadBalancerClientFactory(LoadBalancerClientsProperties properties) {
        super(properties);
    }

    @Override
    public <T> T getInstance(String name, Class<T> type) {
        log.info("调用下游负载均衡服务: {}", name);
        return super.getInstance(name, type);
    }
}
